use chrono::{DateTime,Utc};

use sha2::{Sha256,Digest};
use hex::encode;
declare_dao!(AccountDao {
    id:i64,
    user_id:Option<i64>,
    platform_id:Option<i64>,
    account:Option<String>,
    password:Option<String>,
    token:Option<String>,
    expire:DateTime<Utc>,
    created_at:DateTime<Utc>
};"accounts";i64;id);


impl AccountDao {
    pub fn password_digest(password:&str)->String {
        let mut hasher = Sha256::new();
        hasher.update(password);
        hasher.update(":platforms");
        encode( hasher.finalize())
    }
}